import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';



var datae = [2025,2024,2023,2022,2021,2020,2019,2018,2017,2016,2015,2014,2013,2012,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000];

void showSlectSheet(BuildContext context, {required String title, required List<String> items, required Function(int) onTap}) {
  showModalBottomSheet(
    context: context,
    builder: (BuildContext context) {
      return Container(
        padding: const EdgeInsets.all(16.0),
        child: Container(),
      );
    },
  );
}


typedef CallBackSeck = void Function(int,int);


Future<Map<String, dynamic>?> showSlectSheet1(BuildContext context,{int indexYear=0,int jiduItem =0,required CallBackSeck callBack}) {

  var jiduIdexn =['第一季度','第二季度','第三季度','第四季度'];

  var year = DateTime.now().year;
  final FixedExtentScrollController _yearController = FixedExtentScrollController(initialItem: indexYear);
  final FixedExtentScrollController _monthController = FixedExtentScrollController(initialItem: jiduItem);


 return showModalBottomSheet(
  // showCupertinoModalPopup(
    context: context,
    builder: (_) => ClipRRect(
      borderRadius: BorderRadius.horizontal(left: Radius.circular(15 ),right: Radius.circular(15 )),
      child: Container(
        height: 250,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(12),
          // gradient: const LinearGradient(
          //   colors: [Color(0xFF8AD1FF), Color(0xFF5DD9FF)],
          //   begin: Alignment.topLeft,
          //   end: Alignment.bottomRight,
          // ),
          // boxShadow: [
          //   BoxShadow(
          //     color: const Color(0xFF5DD9FF).withOpacity(0.3),
          //     spreadRadius: 1,
          //     blurRadius: 10,
          //     offset: const Offset(0, 5),
          //   ),
          // ],
        ),
        child: Column(
          children: [
            // 顶部操作栏
            Container(
              padding: EdgeInsets.symmetric(horizontal: 16),
              height: 44,
              decoration: BoxDecoration(
                color: CupertinoColors.white,
                // border: Border(
                //   bottom: BorderSide(color: CupertinoColors.lightBackgroundGray),
                // ),
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  CupertinoButton(
                    onPressed: () => Navigator.pop(context),
                    padding: EdgeInsets.zero,
                    child: Text('取消', style: TextStyle( fontSize: 14,color: CupertinoColors.destructiveRed)),
                  ),
                  CupertinoButton(
                    onPressed: () {
                      callBack(_yearController.selectedItem,_monthController.selectedItem);
                      Navigator.pop(context,{"yearIndex":_yearController.selectedItem,"jiduIndex": _monthController.selectedItem});
                    },
                    padding: EdgeInsets.zero,
                    child: Text('确认', style: TextStyle( fontSize: 14,color: CupertinoColors.activeBlue)),
                  ),
                ],
              ),
            ),
            // 年月选择器
            Expanded(
              child: Row(
                children: [
                  // 年份选择
                  Expanded(
                    child: CupertinoPicker(
                      selectionOverlay: CupertinoPickerDefaultSelectionOverlay(
                          background: Colors.transparent,
                      ),
                      backgroundColor: CupertinoColors.white,
                      scrollController: _yearController,
                      itemExtent: 40,
                      onSelectedItemChanged: (index) {},
                      children: List.generate(50, (index) {
                        return Center(
                          child: Text(
                            '${year - index}年',
                            style: TextStyle(fontSize: 14),
                          ),
                        );
                      }),
                    ),
                  ),
                  // 月份选择
                  Expanded(
                    child: CupertinoPicker(
                      scrollController: _monthController,
                      itemExtent: 40,
                      selectionOverlay: CupertinoPickerDefaultSelectionOverlay(
                        background: Colors.transparent,
                      ),
                      backgroundColor: CupertinoColors.white,
                      onSelectedItemChanged: (index) {},
                      children: List.generate(4, (index) {
                        return Center(
                          child: Text(
                              jiduIdexn[index],
                            style: TextStyle(fontSize: 14),
                          ),
                        );
                      }),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    ),
  );
}




